$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_zjpj_m")
    const dgrid1 = $NG.getCmpApi("")
    const getHeadValue = (str) => mstform.getItem(str).getValue()
    hideHeadKey()
    useValuesChange(() => {
        getXmkInfoByPhid()
    }, "p_form_zjpj_m.u_xmmc")

    useValuesChange(() => {
        hideHeadKey()
    }, "p_form_zjpj_m.u_pjxs")
    // 获取项目库信息
    function getXmkInfoByPhid() {
        const phid = getHeadValue("u_xmmc")
        if (!phid) return
        $NG.execServer("getXmkInfoByPhid", { phid }, (res) => {
            if (res.count == 0) return
            const datas = JSON.parse(res.data)[0].extendObjects
            $NG.updateState((updater) => {
                updater.data.p_form_zjpj_m.setProps({
                    bill_no: datas.u_xmbh,
                    u_gctze: datas.u_ztzje,
                })
            })
        })
    }

    // 隐藏表头字段
    function hideHeadKey() {
        const akey = ['u_pjjd']
        const bkey = ['u_sfwczpj', 'u_zpjwcsj', 'u_hpjysfy']
        let hidden = false
        if (mstform.getItem("u_pjxs").getValue() == '02') {
            hidden = true
        }
        akey.forEach(item => {
            mstform.getItem(item).setProps({
                hidden
            })
        })
        bkey.forEach(item => {
            mstform.getItem(item).setProps({
                hidden: !hidden
            })
        })
    }
})
